﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;
using VOL.Core.Utilities;
using VOL.Entity.DomainModels;
using VOL.MES.IServices;
using VOL.Team.TeamIServices.ProductManagement.IServices;

namespace VOL.WebApi.Controllers.Team.xzc
{
    /// <summary>
    /// 生产管理-工单甘特图
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionManagementController : ControllerBase
    {
        private readonly ITicketLedgerServices _ticketLedgerServices;

        public ProductionManagementController(ITicketLedgerServices ticketLedgerServices)
        {
            this._ticketLedgerServices = ticketLedgerServices;
        }
        /// <summary>
        /// 生产管理-工单甘特图-新增工单台账-xzc
        /// </summary>
        /// <param name="ticketledger"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> AddTicketLedger([FromBody]TicketLedger ticketledger)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var ticketledgerList = await _ticketLedgerServices.AddTicketLedger(ticketledger);
            return webResponseContent.OK("新增工单台账成功", ticketledgerList);
        }
        /// <summary>
        /// 生产管理-工单甘特图-修改工单台账-xzc
        /// </summary>
        /// <param name="ticketledger"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> UpdateTicketLedger([FromBody]TicketLedger ticketledger)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var ticketledgerList = await _ticketLedgerServices.UpdateTicketLedger(ticketledger);
            return webResponseContent.OK("新增工单台账成功", ticketledgerList);
        }
        /// <summary>
        /// 生产管理-工单甘特图-查询工单台账-xzc
        /// </summary>
        /// <param name="ticketledger"></param>
        /// <returns></returns>
        [HttpGet]
        public WebResponseContent GetTicketLedgerList(string? tickeNumber, int? ordersState)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var ticketledgerList = _ticketLedgerServices.GetTicketLedgerList(tickeNumber, ordersState);
            return webResponseContent.OK("查询工单台账成功",ticketledgerList);
        }
        /// <summary>
        /// 生产管理-新增甘特图-BOM查询-xzc
        /// </summary>
        /// <param name="boms"></param>
        /// <returns></returns>
        [HttpGet]
        public WebResponseContent GetBOM()
        {
            WebResponseContent webResponseContent= new WebResponseContent();
            var bomList = _ticketLedgerServices.GetBOM();
            return webResponseContent.OK("BOM查询成功",bomList);
        }
        /// <summary>
        /// 生产管理-新增甘特图-工艺路线查询-xzc
        /// </summary>
        /// <param name="boms"></param>
        /// <returns></returns>
        [HttpGet]
        public WebResponseContent GetOperational()
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var operationalList = _ticketLedgerServices.GetOperational();
            return webResponseContent.OK("工艺路线查询成功", operationalList);
        }
    }
}
